package com.fuyun.rpc.common.exception;

/**
 * RPC异常码枚举
 */
public enum ExceptionCode {

	// 通用异常
	SYSTEM_ERROR("SYSTEM_ERROR", "系统错误"), PARAMETER_ERROR("PARAMETER_ERROR", "参数错误"),

	// 网络相关异常
	NETWORK_ERROR("NETWORK_ERROR", "网络错误"), CONNECT_TIMEOUT("CONNECT_TIMEOUT", "连接超时"), SOCKET_ERROR(
		"SOCKET_ERROR", "套接字错误"),

	// 服务相关异常
	SERVICE_NOT_FOUND("SERVICE_NOT_FOUND", "服务未找到"), SERVICE_UNAVAILABLE("SERVICE_UNAVAILABLE", "服务不可用"),
	SERVICE_CALL_FAILED("SERVICE_CALL_FAILED", "服务调用失败"),

	// 序列化相关异常
	SERIALIZATION_ERROR("SERIALIZATION_ERROR", "序列化错误"), DESERIALIZATION_ERROR("DESERIALIZATION_ERROR",
	                                                                                "反序列化错误"),

	// 注册中心相关异常
	REGISTRY_ERROR("REGISTRY_ERROR", "注册中心错误"), DISCOVERY_ERROR("DISCOVERY_ERROR", "服务发现错误"),

	// 认证相关异常
	AUTHENTICATION_FAILED("AUTHENTICATION_FAILED", "认证失败"), AUTHORIZATION_FAILED("AUTHORIZATION_FAILED",
	                                                                                 "授权失败"),

	// 熔断相关异常
	CIRCUIT_BREAKER_OPEN("CIRCUIT_BREAKER_OPEN", "熔断器开启");

	private final String code;
	private final String message;

	ExceptionCode(String code, String message) {
		this.code = code;
		this.message = message;
	}

	public String getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}
}